/*
 * BehaviorAutomata.h
 * Behavioral Attributed Automaton
 * @author Gregoire JACOB (gregoire.jacob@orange-ftgroup.com)
 * @date 01/12/2008
 * @version 2.2
 * Central header
 */


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#include ".\Includes\Automata.h"
#include ".\Includes\Binary.h"
#include ".\Includes\ObjectDatabase.h"
//Monitored behaviors
#include ".\Includes\Duplication.h"
#include ".\Includes\Propagation.h"
#include ".\Includes\Residency.h"
#include ".\Includes\Overinfection.h"
#include ".\Includes\ActivityTest.h"
#include ".\Includes\ExecutionProxy.h"



static char typestr[7][15] = {"unknown","var","objperm","objtemp",
								  "objcom","objboot","this"};
static char eventstr[8][15] = {"stop","affect","open","create",
								  "close","delete","read","write"};
static char limitstr[6][4] = {"","(",")*","{","}","|"};

int nbevent;
int nbambiguous;
FILE * pf_BehDB;

/**
 * getEvent()
 * @param the open log file
 * @param the variable to store the first argument identifier
 * @param the variable to store the first argument type
 * @param the variable to store the second argument identifier
 * @param the variable to store the second argument type
 * @return the recovered event or -1
 */
unsigned long getEvent(FILE * log, long * arg1id, int * arg1type,
					   long * arg2id, int * arg2type);

#define DUPLICATION_REF		0
#define PROPAGATION_REF		1
#define RESIDENCY_REF		2
#define OVERINFECTION_REF	3
#define EXECUTIONPROXY_REF	4
/**
 * storeBehaviorEntry()
 * @param the database file where behaviors are stored
 * @param the behavior reference
 * @param the implemented method
 * @param the involved objects (until three objects)
 */
void writeXMLPreamble(FILE * db);
void storeBehaviorEntry(FILE * db, int behref, int method, 
						long obj1id, long obj2id, long obj3id);